<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE composition PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<ui:composition xmlns:ui="http://java.sun.com/jsf/facelets"
                template="./../resources/main.xhtml"
                xmlns:h="http://xmlns.jcp.org/jsf/html"
                xmlns:f="http://xmlns.jcp.org/jsf/core"
                xmlns:p="http://primefaces.org/ui"
                xmlns="http://www.w3.org/1999/xhtml">

    <ui:define name="content">
        <h:outputStylesheet library="css" name="estilo.css" />
        <p:separator />
        <div class="pagina">
            Cadastro de Acesso
        </div>
        <p:separator />
        <h:form id="frmAcesso">
            <p:growl />
            <h:inputHidden value="#{mbAcesso.acesso.idAcesso}" />            
            <h:panelGrid columns="2">
                <h:outputLabel value="Funcionario.:" styleClass="lb" />
                <h:selectOneMenu value="#{mbAcesso.acesso.funcionario.idFuncionario}" styleClass="tx">
                    <f:selectItem itemValue="0" itemLabel="Selecionar" />
                    <f:selectItems value="#{bbFuncionario.funcionarios}" var="f" itemValue="#{f.idFuncionario}" itemLabel="#{f.nome}" />
                </h:selectOneMenu>
                <h:outputLabel value="Login.:" styleClass="lb" />
                <h:inputText value="#{mbAcesso.acesso.login}" styleClass="tx" validatorMessage="Login com minimo 5 no maximo 10 caracter">
                    <f:validateLength maximum="10" minimum="5" />
                </h:inputText>
                <h:outputLabel value="Senha.:" styleClass="lb" />
                <h:inputSecret value="#{mbAcesso.acesso.senha}" styleClass="tx" validatorMessage="Senha com minimo 5 no maximo 10 caracter" required="true">
                    <f:validateLength maximum="10" minimum="5" />
                </h:inputSecret>
                <h:outputLabel value="Confirmar Senha.:" styleClass="lb" />
                <h:inputSecret value="#{mbAcesso.confereSenha}" styleClass="tx" />                
                <h:outputLabel value="Ativo.:" styleClass="lb" />
                <h:selectBooleanCheckbox value="#{mbAcesso.acesso.ativo}" styleClass="tx"/>
                <p:commandButton value="Cancelar" action="#{mbAcesso.limparAcesso}"  immediate="true" ajax="false" update="@form" />
                <p:commandButton value="Salvar" action="#{mbAcesso.salvarAcesso}" ajax="false" update="@form" />
            </h:panelGrid>
        </h:form>
        <h:form>
            <p:dataTable value="#{mbAcesso.acessos}" var="a">
                <p:column>
                    <h:outputText value="#{a.funcionario.nome}" styleClass="txt"/>
                </p:column>
                <p:column>
                    <h:outputText value="#{a.login}" styleClass="txt" />
                </p:column>
                <p:column headerText="Alterar" style="text-align: center; font-size: 12px;" width="30">
                    <p:commandLink process="@this" update=":frmAcesso" ajax="false" styleClass="txt" title="Alterar">
                        <f:setPropertyActionListener target="#{mbAcesso.acesso}" value="#{a}" />
                        <h:graphicImage library="img" name="edicao.png" />
                    </p:commandLink>
                </p:column>
            </p:dataTable>
        </h:form>
    </ui:define>
</ui:composition>
